import { Global, Module } from '@nestjs/common'
import { AnalyticsService } from './analytics.service'
import { ConfigModule, ConfigService } from '@nestjs/config'
import { NotifyClientModule } from '@boticord/notify-client'

@Module({
  imports: [
    ConfigModule.forRoot({
      ignoreEnvFile: true,
    }),
    NotifyClientModule.forRootAsync({
      imports: [ ConfigModule ],
      inject: [ ConfigService ],
      useFactory: (cfg: ConfigService) => ({
        rpcSecret: cfg.getOrThrow('RPC_SECRET'),
      }),
    }),
  ],
  providers: [ AnalyticsService ],
  exports: [ AnalyticsService ],
})
@Global()
export class AnalyticsModule {}
